const app = getApp();
Page({
    data:{
        list: [],
        content: "",
        isvoer: true,
        userInfo: {},
        specially:"#00cc66",
        costar:'#00cc66'
    },
    onLoad(){
      const {specially,costar} = app.theme;
      let userInfo = app.functions.getLocalStorage("user");
      let str = "";
        for (let key in app.data.TeamProducts) {
            str += "\r🍁" + key + "🍁\r";
            app.data.TeamProducts[key].forEach((item, ind, arr) => {
                item.marketprice = item.marketprice;
                str += "🍀" + item.title + "";
                if (item.specTitle) {
                    str += "(" + item.specTitle + ")";
                }
                str += item.marketprice + '元 \r';
            });
        }
      this.setData({
        content: str,
        list:app.data.TeamProducts,
        specially,
        costar,
        userInfo
      })
    //   this.products();
    },
    products() {
        let that = this;
        let userInfo = app.functions.getLocalStorage("user");
        let params = {
            mid: userInfo.id,
        };
        app.api.shopMemberProducts(params, (res) => {
            let str = "";
            for (let key in res.data) {
                str += "\r🍁" + key + "🍁\r";
                res.data[key].forEach((item, ind, arr) => {
                    item.marketprice = item.marketprice.toFixed(2);
                    str += "🍀" + item.title + "";
                    if (item.specTitle) {
                        str += "(" + item.specTitle + ")";
                    }
                    str += item.marketprice + '元 \r';
                });
            }
            that.setData({
                content: str,
                list: res.data,
                isvoer: true
            })
        }, (err) => {
            that.setData({
                isvoer: false
            })
        })
    },
    copy() {
        wx.setClipboardData({
            data: this.data.content,
            success(res) {
                wx.getClipboardData({
                    success(res) {
                    }
                });
            }
        });
    },
    toGoodsDeatil(e) {
      let goodsid=e.currentTarget.dataset.id;
      let shareid = app.functions.getLocalStorage("shareUserId");
      let shop = app.functions.getLocalStorage("shop");
      wx.navigateTo({
        url: '/pages/detail/detail?goodsid='+goodsid+'&shopid='+shop.id+'&shareid='+shareid
      })
    }
})